package com.qidianit.mes.md.controller;

import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.md.service.ClassifyService;
import com.qidianit.mes.pojo.MaterialClassify;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 奇幻夜之梦
 * @Company 起点编程
 * @Description
 * @Time 2024/10/16 1:09
 */
@RestController
@CrossOrigin
@RequestMapping("/materialClassify")
public class ClassifyController {
    @Autowired
    private ClassifyService classifyService;
    @PostMapping("/save")
    public MESResult save(@RequestBody MaterialClassify materialClassify) {
        return  classifyService.save(materialClassify);
    }
    @GetMapping("/list")
    public MESResult list(MaterialClassify materialClassify, Long parentId){
        return classifyService.list(materialClassify,parentId);
    }
    @GetMapping("selectById")
    public MESResult selectById(Long classifyId) {
        return classifyService.selectById(classifyId);
    }

    @PutMapping("/update")
    public MESResult update(@RequestBody MaterialClassify materialClassify) {
        return classifyService.updateClassify(materialClassify);
    }

    @GetMapping("/countSubclassify")
    public MESResult countSubclassify(Long classifyId) {
        return classifyService.countSubclassify(classifyId);
    }

    @DeleteMapping("/delete")
    public MESResult delete(Long classifyId){
        return classifyService.delete(classifyId);
    }
    @GetMapping("getTree")
    public MESResult getTree(Long parentId){
        return classifyService.getTree(parentId);
    }
}

